home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15086 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: global.gc.net!sourcebbs!david.mohorn
  2. From: david.mohorn@sourcebbs.com (DAVID MOHORN)
  3. Newsgroups: comp.lang.c
  4. Subject: COLLEGE PROFESSORS! #2
  5. Message-ID: <8BEC555.02C70031C5.uuout@sourcebbs.com>
  6. Date: Tue, 16 Apr 96 22:45:00 -0500
  7. Distribution: world
  8. Organization: SelectiveSourceBBS VirginiaBeach  (804)471 6776
  9. Reply-To: david.mohorn@sourcebbs.com (DAVID MOHORN)
  10. X-Newsreader: PCBoard Version 15.22
  11. X-Mailer: PCBoard/UUOUT Version 1.20
  12.  
  13. For those who may have found my previous message entertaining to
  14. read--and totally absurd--here another from last week.
  15.  
  16. We have a program that reads a sequential file (50 items or so) and
  17. placed these items in an array.  Items can be added and deleted from the
  18. array.  There is only one catch, however.  If you delete an item, it
  19. really doesn't get deleted.
  20.  
  21. This is the instructors way of deleting an item from an array:
  22.  
  23. declare main_array variable for 50 elements
  24. declare del_array variable for 50 elements
  25.  
  26. When an array item is deleted, clear the data within the array, place
  27. element number in del_array array.
  28.  
  29. When an item is added to the main_array, first scan the del_array array
  30. to see if any items have been deleted.  If so, use the value within the
  31. array to denote what element within the main_array can be used for this
  32. new data.  If there are no deleted items in the del_array, add new item
  33. at end of main_array.
  34.  
  35. Doesn't this technique make the least amount of sense!?!?!?  Now instead
  36. of maintaining only one array constructs, you have to maintain two:
  37. main_array and del_array.  This also requires twice as much memory!
  38.  
  39. My solution in deleting an element is to simply shift all elements
  40. above the element being deleted down one element.  When a new element is
  41. added, it is added to the end of the array.  For this many items, there
  42. shouldn't be any noticeable delay.  If it were say, 500 items, I'd might
  43. think about having a "flag" field with each array indicating whether it
  44. was active or or inactive and keying on the flag.
  45.  
  46. When I mentioned my technique to the instructor, he said his way is
  47. easier to read!  When I mentioned to him about how his program now
  48. requires more memory, he said "memory is cheap now days, so there is no
  49. concern about saving memory..."
  50.  
  51. This is just the type of injudicious crap an instructor needs to be
  52. teaching future, potential programmers!  With this instructor's
  53. mentality, no wonder code today is bloated and requires a Pentium
  54. processor to run!
  55.  
  56. Does anyone else have any opinions or horror stories?
  57.  
  58. RIME: ->1369 FIDO: (1:275/102) INTERNET: david.mohorn@sourcebbs.com
  59.  
  60. ---
  61.  * QMPro 1.53 * Spaghetti code is computer lingo for job security.
  62.  
  63.  
  64. ---
  65. This message originated from:  ----------        Selective Source BBS
  66.                                     -------    Virginia Beach, Virginia
  67.                                          -----      (804) 471 6776
  68.